package br.com.lambdacore.persistence.dao;

import br.com.lambdacore.domain.model.EntityModel;

import javax.persistence.LockModeType;
import java.util.Collection;
import java.util.Map;

public interface SqlDAO<T extends EntityModel> extends DAO<T> {

	boolean contains(T entity);

	Collection<? extends T> find(String query);

	Collection<? extends T> find(String query, Map<String, Object> parameters);

	Collection<? extends T> findFirstResult(String query, Integer firstResult);

	Collection<? extends T> findFirstResult(String query,
											Map<String, Object> parameters, Integer firstResult);

	Collection<? extends T> findMaxResults(String query, Integer maxResults);

	Collection<? extends T> findMaxResults(String query,
										   Map<String, Object> parameters, Integer maxResults);

	Collection<? extends T> findRange(String query, Integer firstResult,
									  Integer maxResults);

	Collection<? extends T> findRange(String query,
									  Map<String, Object> parameters, Integer firstResult,
									  Integer maxResults);

	T findSingleResult(String query);

	T findSingleResult(String query, Map<String, Object> parameters);

	T getReference(T entity);

	void lock(T entity, LockModeType lockModeType);

	void lockRead(T entity);

	void lockWrite(T entity);

	void refresh(T entity);

}
